home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / docs / Var_Dump / example-1.php next >
Encoding:
PHP Script  |  2004-10-01  |  1.5 KB  |  89 lines

  1. <?php
  2.  
  3. include_once 'Var_Dump.php';
  4.  
  5. echo '<h1>example1.php : displaying a variable</h1>';
  6.  
  7. /*
  8.  * example1.php : displaying a variable
  9.  *
  10.  * To display a variable :
  11.  *
  12.  *   Var_Dump::display($variable);
  13.  *
  14.  * To return a variable :
  15.  *
  16.  *   $str = Var_Dump::display($variable, TRUE);
  17.  *
  18.  */
  19.  
  20. /*
  21.  * Initialise the HTML4 Table rendering
  22.  */
  23.  
  24. Var_Dump::displayInit(array('display_mode'=>'HTML4_Table'));
  25.  
  26. /*
  27.  * Displays an array
  28.  */
  29.  
  30. echo '<h2>Array</h2>';
  31.  
  32. $fileHandler=tmpfile();
  33. $linkedArray=array('John', 'Jack', 'Bill');
  34. $array=array(
  35.     'key-1' => 'The quick brown fox jumped over the lazy dog',
  36.     'key-2' => 234,
  37.     'key-3' => array(
  38.         'key-3-1' => 31.789,
  39.         'key-3-2' => & $linkedArray,
  40.         'file'    => $fileHandler
  41.     ),
  42.     'key-4' => NULL
  43. );
  44. Var_Dump::display($array);
  45.  
  46. /*
  47.  * Displays an object (with recursion)
  48.  */
  49.  
  50. echo '<h2>Object (Recursive)</h2>';
  51.  
  52. class parent {
  53.     function parent() {
  54.         $this->myChild = new child($this);
  55.         $this->myName = 'parent';
  56.     }
  57. }
  58. class child {
  59.     function child(&$parent) {
  60.         $this->myParent =& $parent;
  61.     }
  62. }
  63. $recursiveObject=new parent();
  64. Var_Dump::display($recursiveObject);
  65.  
  66. /*
  67.  * Displays a classic object
  68.  */
  69.  
  70. echo '<h2>Object (Classic)</h2>';
  71.  
  72. class test {
  73.     var $foo=0;
  74.     var $bar="";
  75.     function get_foo() {
  76.         return $this->foo;
  77.     }
  78.     function get_bar() {
  79.         return $this->bar;
  80.     }
  81. }
  82. $object=new test();
  83. $object->foo=753;
  84. $object->bar="357";
  85. Var_Dump::display($object);
  86.  
  87. fclose($fileHandler);
  88.  
  89. ?>